# try:
#     input_str = input("输入一个数字")
#     input_value = int(input_str)
#     # print(f"输入的值是" + input_value)
#     if input_value % 2:
#         print(f"奇数")
#     else:
#         print(f"偶数")
# except TypeError as e:
#     print(f"类型错误")
# except ValueError as e:
#     print(f"值错误")
# except Exception as e:
#     print(f"出异常了,  也不知道什么异常", e)
# else:
#     print("恭喜你计算没有出异常")
# finally:
#     print(f"不管是否有异常 都要执行")


# try:
#     with open("hello.py", "r") as f:
#         print(f.read())
#
# except:
#     print(f"出异常了")
# print(f"程序运行结束")


# import re
#
# class VarException(Exception):
#     def __init__(self, *args):
#         super().__init__(f"Waring: {args[0]}")
#
#
#
# def get_var():
#     while True:
#         var_str = input("输入一个变量名")
#         if re.search(r'[A-Z]', var_str):
#             # print(f"变量名不能包含大写")
#             raise VarException("变量名不能包含大写")
#         else:
#             print(f"变量名合法")
#             return var_str
#
#
# try:
#     v = get_var()
# except VarException as e:
#     print(e)
# except Exception as e:
#     print(e)


try:
    raise Exception("就是睡不醒")
except Exception as e:
    print(e)
print(f"程序结束")